// ==UserScript==
// @include	   *imvu.com*
// ==/UserScript==
window.addEventListener('DOMContentLoaded', function() {
   if( widget.preferences.strip == "enabled" ){
   var doc2 = document.location.href;
   if(document.domain.indexOf("imvu.com") > -1){
     	if(doc2.search("avatars.imvu.com") > -1 || doc2.search("imvu.com/catalog/web_mypage.php") > -1){
		document.title = document.title.replace('IMVU: My avatar page: Guest_', '').replace('IMVU: My avatar page: ', '');}
	else if(doc2.search("name=phpbb2") > -1){
 		document.title = document.title.replace('IMVU - View topic - ', '').replace('&amp;', '&').replace('IMVU - View Forum - ', '').replace('IMVU - Index', 'Forum Overview').replace(/&quot;/g, '"').replace('- IMVU Related', '').replace('- NEW', '');}
 	else if(doc2.search("imvu.com/shop") > -1 || doc2.search("imvu.com/catalog/products_new.php") > -1 || doc2.search("imvu.com/catalog/web_prod_tag_search_result.php") > -1){
 		document.title = document.title.replace('IMVU Catalog: ', '').replace('IMVU Product: ', '').replace(': Shop - IMVU', '');}
 	else if(doc2.search("imvu.com/groups") > -1){
 		if(doc2.search("imvu.com/groups/group/") > -1){
		var grouptitle = document.getElementById("breadcrumb").childNodes[5].childNodes[0].textContent;
		document.title = grouptitle;}
		else{document.title = document.title.replace('IMVU: Group: ', '').replace(' - IMVU Groups', '').replace('IMVU Groups: Meet new people with the same interests', 'Groups');}}
	else if(doc2.search("imvu.com/music/album.php") > -1){
		var albumpagetitle = document.getElementById("breadcrumb").childNodes[9].childNodes[0].wholeText;
	    	document.title = albumpagetitle;}	
	else if(doc2.search("imvu.com/music/genre.php") > -1){
	    	var genrepagetitle = document.getElementById("breadcrumb").childNodes[5].childNodes[0].wholeText;
		document.title = genrepagetitle;} 
	else if(doc2.search("imvu.com/music/artist.php") > -1){
	    var musicpagetitle = document.getElementById("breadcrumb").childNodes[7].childNodes[0].textContent;
		document.title = musicpagetitle;} 
 	else if(doc2.search("imvu.com/music/") > -1){
 		document.title = document.title.replace('IMVU Music', 'Music Store');}
	else if(doc2.search("imvu.com/catalog/newsletter/video.php") > -1){
		document.title = 'Videos';}
	else if(doc2.search("imvu.com/neighborhoods/") > -1){
 		document.title = document.title.replace('3D Chat', 'Public').replace('Virtual ', '').replace(': IMVU', '');}
 	else if(doc2 == "imvu.com/catalog/invite/inviter.php"){
 		document.title = 'Invite a friend';}
	else if(doc2 == "imvu.com/catalog/gifts.php?nav_section=shopping&nav_subsection=gifts"){
 		document.title = 'Gifts';}
  	else if(doc2 == "imvu.com/catalog/shopping_cart.php"){
  		document.title = 'Shopping Cart';}
 	else if(doc2 == "imvu.com/catalog/web_index.php/music"){
 		document.title = 'Manage Mixes';}
	else if(doc2 == "imvu.com/catalog/web_index.php/updates"){
 		document.title = 'Updates';}
	else if(doc2 == "imvu.com/catalog/web_info.php?topic=terms_of_service"){
 		document.title = 'Terms of Service';}
	else if(doc2 == "imvu.com/catalog/web_info.php?topic=mature_content_policy"){
 		document.title = 'Virtual Goods Policy';}
	else if(doc2 == "imvu.com/catalog/web_info.php?topic=privacy"){
 		document.title = 'Privacy Policy';}
	else if(doc2.search("imvu.com/catalog/web_credits_balance_log.php") > -1){
 		document.title = 'Credit Balance Log';}
 	else if(doc2.search("imvu.com/creators/") > -1){
		document.title = document.title.replace(' - IMVU Creator', '');}
	else if(doc2.search("imvu.com/games/") > -1){
		if(doc2.search("imvu.com/games/play/") > -1){
		var gstr = doc2.substr(1).split("/")[6];
		var gresult = gstr.charAt(0).toUpperCase() + gstr.slice(1);
		document.title = gresult;}
		else if(doc2.search("http://www.imvu.com/games/category/") > -1){
		var gcatname = document.getElementById("category-title").childNodes[0].textContent;
		document.title = gcatname;}
		else{document.title = document.title.replace('IMVU: ', '').replace(' : IMVU', '').replace(': IMVU', '');}}
 	else{document.title = document.title.replace('IMVU: ', '').replace(' : IMVU', '').replace(': IMVU', '').replace(': 3D Chat Rooms', '');}
}}
}, true);